#pragma once
//#include "KillProcessDlg.h"
#include <psapi.h>

#include <vdmdbg.h>
#include <afxcoll.h>
#include <afxtempl.h>
#include <tlhelp32.h>
typedef BOOL (WINAPI *TEnumProcesses)(
	DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded
);

typedef BOOL (WINAPI *TEnumProcessModules)(
    HANDLE hProcess, HMODULE * lphModule, DWORD cb, LPDWORD lpcbNeed
);

typedef DWORD (WINAPI *TGetModuleFileNameEx)(
  HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename, DWORD nSize         
);

// CProcessTree

class CProcessTree : public CTreeCtrl
{
	DECLARE_DYNAMIC(CProcessTree)
	friend class CKillProcessDlg;
public:
	CProcessTree();
	virtual ~CProcessTree();
	int m_iChoose;
	bool m_bShowInfo;
protected:
	DECLARE_MESSAGE_MAP()
	DWORD *m_pProcesses;
	HMODULE *m_pModules;
	DWORD m_dwMaxCount;
	DWORD m_dwCount;
	DWORD m_dwMaxModule;
	CImageList m_imgList;
	SHFILEINFO m_shFinfo;

	CMap<HTREEITEM,HTREEITEM,DWORD *,DWORD *> m_map;
	CMap<HTREEITEM,HTREEITEM,DWORD *,DWORD *> m_mapModule;
	CKillProcessDlg *m_pMain;
	TEnumProcesses KEnumProcesses;
	TEnumProcessModules KEnumProcessModules;
	TGetModuleFileNameEx KGetModuleFileNameEx;

public:
	void DisplayTree(void);
	afx_msg void OnTvnItemexpanded(NMHDR *pNMHDR, LRESULT *pResult);
	void ReFresh(void);
	afx_msg void OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult);
	void ShowInfo(HTREEITEM);
	HTREEITEM AddItem(char * sFile,HTREEITEM hTreeItem=TVI_ROOT);
	int EnumThreads(DWORD dwProcessID);
	afx_msg void OnNMRclick(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnKillProcess();
	afx_msg void OnFree();
	afx_msg void OnEndthread();
};


